package com.seminario.spring.dao.caralibro;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.seminario.spring.dao.DAOImpl;
import com.seminario.spring.domain.Muro;
import com.seminario.spring.domain.Perfil;
@Repository
public class MuroDAOImpl extends DAOImpl<Muro> implements MuroDOA {

	@Override
	protected Class<Muro> getEntityClass() {
		return Muro.class;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Muro> getAll() {
		String query = "Select m From Muro m";
		List<Muro> muros = (List<Muro>) entityManager.createQuery(query).getResultList();
		return muros;
	}

	@Override
	public Muro getMuro(Perfil perfil) {
		String query = "Select m From Muro m Where m.perfil.id = :perfilId";
		Muro muro = (Muro) entityManager.createQuery(query).setParameter("perfilId", perfil.getId()).getSingleResult();
		return muro;
	}

}
